﻿using S2Cloud.SmartFlow.GrpcHelper;
using System.Collections.Generic;

namespace S2_Xxxx_XxxNetApi
{
    /// <summary>
    /// 表单相关操作，用法见语雀 https://www.yuque.com/s2/xmss/insex9#i4a9J
    /// </summary>
    public class FormHelper
    {
        /// <summary>
        /// 工作流表单：发起暂存
        /// </summary>
        /// <param name="objectId">	数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <param name="directory">表单数据</param>
        public static void StartSave(string objectId, string code, string userId, Dictionary<string, string> directory)
        {
            GrpcClientSingle.S2GrpcClient.formManager.StartSave(objectId, code, userId, directory);
        }

        /// <summary>
        /// 工作流表单：发起提交
        /// </summary>
        /// <param name="objectId">数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <param name="directory">表单数据</param>
        public static void StartSubmit(string objectId, string code, string userId, Dictionary<string, string> directory)
        {
            S2Cloud.SmartFlow.GrpcHelper.Entity.Result<string> result = GrpcClientSingle.S2GrpcClient.formManager.StartSubmit(objectId, code, userId, directory);
        }

        /// <summary>
        /// 工作流表单：流转中暂存
        /// </summary>
        /// <param name="objectId">	数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <param name="flowId">流程id</param>
        /// <param name="directory">表单数据</param>
        public static void SaveForm(string objectId, string code, string userId, string flowId, Dictionary<string, string> directory)
        {
            GrpcClientSingle.S2GrpcClient.formManager.Save(objectId, code, userId, flowId, directory);
        }

        /// <summary>
        /// 工作流表单：流转中提交
        /// </summary>
        /// <param name="objectId">	数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <param name="flowId">流程id</param>
        /// <param name="directory">表单数据</param>
        public static void SubmitForm(string objectId, string code, string userId, string flowId, Dictionary<string, string> directory)
        {
            GrpcClientSingle.S2GrpcClient.formManager.Submit(objectId, code, userId, flowId, directory);
        }

        /// <summary>
        /// 获取表单数据
        /// </summary>
        /// <param name="objectId">数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public static dynamic GetFormQuery(string objectId, string code, string userId)
        {
            return GrpcClientSingle.S2GrpcClient.formManager.GetFormQuery(objectId, code, userId);
        }

        /// <summary>
        /// 修改表单数据
        /// </summary>
        /// <param name="objectId">数据id</param>
        /// <param name="code">功能code</param>
        /// <param name="userId">用户id</param>
        /// <param name="directory">表单数据</param>
        public static void UpdateFormData(string objectId, string code, string userId, Dictionary<string, string> directory)
        {
            GrpcClientSingle.S2GrpcClient.formManager.UpdateFormData(objectId, code, userId, directory);
        }

    }
}
